Also replaced StringIO.StringIO by BytesIO in some other appropriate places. StringIO is not available in Python 3.