Do from io import open for python 2.x compatibility.
Fix some print statments for Python3 compatibility.