use io.BytesIO and cStringIO instead of six.BytesIO as suggested