python3 portability

python3 portability, tested with py2.7 and py3.3