Update code to use Python3 (tested with Python 3.1.3)