Fix StringIO on Python 3