Python 3.3 compatible changes
Added encoding in files
Replaced call to file with open
Removed unused variables and imports
Replaced by immutable argument