def dump(self, stream=None, encoding='utf8', encoding_errors='ignore'):  # pylint: disable=arguments-differ
        """Writes a stream to a file.

        :param stream:
            An ``io.StringIO`` instance. A ``basestring`` is also possible and
            get converted to ``io.StringIO``.

        :param encoding: (optional)
            The character encoding of the file.

        :rtype: TextFile
        """
        if stream is None:
            stream = StringIO()

        if isinstance(stream, string_types):
            stream = StringIO(stream)

        stream = self.codec.compress(
            BytesIO(stream.read().encode(encoding, encoding_errors))
        )
        self.fs.dump(stream)

        return self