ALGORITHM TO TRANSFORM IMAGE DATA FORMATS