def _write_str(self, data):
        """
        Converts the given data then writes it

        :param data: Data to be written
        :return: The result of ``self.output.write()``
        """
        with self.__lock:
            self.output.write(
                to_str(data, self.encoding)
                .encode()
                .decode(self.out_encoding, errors="replace")
            )