Iv'e done this before successfully ... and you really only have one option as far as I can see.
You have to call the script twice. Call it once to generate the HTML page and to create the image map, then, in the img tag for your image, place a call to the script again, with the same params, but also an additonal flag to tell it to output the image this time.
Unfortunately, you know have to call the script twice, but its better than the alternative of storing a file on the server which is definetly not the best way to do it.
Hope this helps,
Carl