injunjoel has the best advice so far: move your image generation into a seperate CGI, and refrence the URL of that CGI in your IMG SRC tag.
If, for some reason, you really *MUST* have only one script, then you a super search for "inline images" suggests these node:
In reply to Re: GD::Graph in HTML
by hossman
in thread GD::Graph in HTML
by cosmicsoup
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |