python-pillow/Pillow — pull request #1011 by mfergie (2014-11-14 12:39:04+00:00)
Title: Fix for saving TIFF image into an io.BytesIO buffer

Hi,

When trying to save to a io.BytesIO() I am getting the following error (on python 2.7.8 and 3.4.2):

```
Traceback (most recent call last):
File "pillow-tiff-string-buffer.py", line 15, in
pilim.save(string_buffer, format="tiff", compression='tiff_lzw')
File "/usr/local/lib/python2.7/site-packages/PIL/Image.py", line 1685, in save
save_handler(self, fp, filename)
File "/usr/local/lib/python2.7/site-packages/PIL/TiffImagePlugin.py", line 1127, in _save
_fp = os.dup(fp.fileno())
io.UnsupportedOperation: fileno
```

The enclosed changes rectify this issue by catching the exception instead of relying on the `hasattr` test.

I'm not sure where I should create the unit-test, but I have created a minimal gist to reproduce:
https://gist.github.com/mfergie/c3baa78d1c1b1a9a239b

Note, this only happens when specifying compression when saving.