fix StringIO to work with both py2/p3