Bug fix

infinite loop, while generating image.
Fix header