Handle cStringIO / io module for Python 3