Fix coding errors. Added test for gray scaling.