We need a little more explanation, this question is sort of vague. If $script actually generates the JPEG binary code, then you could probably modify the script to write to STDOUT, although I don't really see the point.
However, it looks like you are using $program to do some processing. In that case, if $program is compiled, and actually writes the JPEG to a filehandle that you can't change then probably not.
I could be way off base here, but I would need a better explanation of what is going on to be sure.
Comment on Re: Redirect file write from external program to STDOUT
And the program.exe writes a jpeg file. script.file contains the instruction. `echo $script | $program` is simply another way to do it without physically a script.file.