implented image color transformation; some code optimization