fixed bug in image optimization.