be python 3 compatible where possible