Fixing for Python3 (tested on Python 3.3.2)