Python 3 Compatibility

These small changes make bernhard work on Python 3.