Altered encoding keyword arguments to make this branch backwards compatible with python2