Hi:
The technique you show is generally one used when copying a file (and/or possibly changing the file with the code in the program). In your code, the file is being read ffrom and written to the same physical storage location. When you are dealing with the Platform and _WEBOUT, you do NOT have a physical storage location, you have a "pipeline" between the requesting client application and the server machine processing the stored process.
_WEBOUT, in the context of the Platform, works a bit differently from a simple HTTP stream. If your client is a browser or is able to read streaming output, then the Platform servers deal with your content in one way, an appropriate way for an HTTP stream (which is frequently why you need to control the content-type heders if your stream is not text/html). If your client is NOT a browser or capable of handling HTTP streams (such as PowerPoint, for example), then the Platform servers generally turn the SP results into SASReport XML.
For sites running SAS/IntrNet, it was always guaranteed that the _WEBOUT pipeline would handle HTTP streams. The receiving clients know what to do with content from an HTTP stream.
When your jpeg comes down the pipeline, what do you want your browser to do??? Will your stored process users know that they're going to get a picture with no wrapper text?? Do all the browsers have plug-ins to open/render the picture???
You might need to use your program to publish your image to a package. You might need to add some more HTML wrapper text to your stored process. The best resource for your question is Tech Support. You can send them all your code, they can query you about your applications and your Platform configuration and help you arrive at an answer.
cynthia