Help with imagecreatetruecolor()

I’m working on a flash project (joncazier.com/avatarnator) right now that involved saving out bitmap data from a flash file to a PHP script that converts it into an image using imagecreatetruecolor. It works mostly ok. But, when I right click on the image, it saves the php file rather than a jpg.

To see this, go to the link I provided above, click save, wait a minute (sorry no loading bar yet) then a new tab will open up with the image.

You can see the PHP script I used here.

I would like that ability to at least right click and save a jpg image or, even better, a prompt to download the image.

Thanks for the help!