First attempt at making utils.py compatible with Python 2 and 3.