Use encode option to open for python 3.0+