Make printing Python 3 compatible.
Fix a few issues found by pylint.