Optimize image generation