Use io.BytesIO() in favor of StringIO to be python3 friendly