Memory jpeg output fix

Howdy!
I had a bit of trouble using your excellent epeg library with memory based files. After a bit of digging, I found the attached bug (and fix).
Perhaps others would find this useful too.
Thanks,
Peter