since I don't know what you were doing with the output I can't comment. I tested the code by pasting the output into an htm file and that loaded the image perfectly in IE.