Image save to stream truncates data

Noticed images were being truncated. This only happens when using the file parameter to image.save. A simple buffer flush fixes the issue.