Python 3 compatible

Fix to make it all work in Python 3 again.