Add Python 3 compatibility.

Mostly just print statements. The other options make almost no
difference here.
Remove unnecessary use of sys.stdout.
Merge pull request #1 from QuLogic/py3

Add Python 3 compatibility.