fixed bug in image generation