TST: use BytesIO to save images into file-like object

StringIO does not work on Python 3
Merge pull request #768 from cgohlke/patch-2

TST: use BytesIO to save images into file-like object