Updated to work with Python 3.x
fixed for Python 3 support