Import cStringIO for Python 2, fallback to BytesIO

Attempting to import BytesIO causes errors with Python 2.
Import cStringIO for Python 2 and fallback to BytesIO for Python 3.