Yes that was my idea but the problem is that the script is run from the browser. It then needs to generate the image from data sent by the browser and return a HTML page with with the image tag in there.
Ofcourse I could use the data sent by the browser and use it to execute the image script but I would like to minimze data sent as much as possible (it's for a mobile app). I would rather just have the image be generated to a fileand then displaying it by way of its filename and then deleting it again.