Python 2 compatibility

* removed incompatible use of print
* rewired StringIO for Python 2