<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, data):
 """Writes data to the stream. :param data: bytes, FLV data to write to the stream The data passed can contain multiple FLV tags, but it MUST always contain complete tags or undefined behaviour might occur. Raises :exc:`IOError` on error. """

        if isinstance(data, bytearray):
            data = bytes(data)

        if not isinstance(data, byte_types):
            raise ValueError("A bytes argument is required")

        res = librtmp.RTMP_Write(self.client.rtmp, data, len(data))

        if res < 0:
            raise IOError("Failed to write data")

        return res