<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _write(self, to_write):
 """ Helper to call encode before writing to file for Python 3 compat. """

        self._file.write(to_write.encode(self._encoding or
                                         self._default_encoding))