Make 1.5.1 build Python3 compatible

This change is *completely untested* on Python2. Please test it before merging!