This is using `text` from `_read_file`, above. `_read_file` uses `open(filename)` but doesn't open with binary access, which means [newline characters may get converted](http://docs.python.org/2/library/functions.html#open) from platform-specific newlines to `\n`, corrupting the image data.

If you get a chance, could you move the mimetype check up, something like `is_image = mimetype.startswith("image/")`, add a `mode` parameter to `_read_file`, and then pass 'b' to it when `is_image` is true?

If not, I'll fix this over the weekend.

Again, thanks for this patch! I appreciate it!