Use six comaptibilty library for StringIO