fix TypeError in python3

This isn't particularly elegant, but it works.