I don't have experience on this, but I think that you can make the script return the image "contents" directly to the img tag, without passing it to a img file, so you can use something like this: <img src="script_that_return_image_contents"> wich saves some processing and I/O.