code: def write(self, arg, **kwargs):
          
          if hasattr(arg, 'seek'):
              self._tofile(arg, **kwargs)
          else:
              with open(arg, 'wb') as fid:
                  self._tofile(fid, **kwargs)
docs: Write instance to file.