Python 3 and PEP8 compatibility

This is what I came up with after short discussion in #52. This is 2to3, pep8 and autopep8 checked plus all tests pass on my side. Please review.