StringIO fixes for compatibility b/t py2/3