It seems that everybody is missing the point or I have not described the problem properly? The image IS getting generated just fine, there are no errors in the error logs - I mentioned in my initial post that a subsequent refresh is required in order to make the image appear in the browser and I am not sure what measures to take to make the image load the first time the page is loaded. (I also mentioned the code works on Apache, but not IIS.) I did show what I believed to be the important line of code and described how it was called, I'm sorry if that was too vague.