Add Python 3 compatibility

StringIO moved to the `io` module in Python 3.