<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 writable bio. For test purposes """

        if pyver == 2:
             if isinstance(data, unicode):
                data = data.encode("utf-8")
             else:
                data = str(data)
        else:
             if not isinstance(data, bytes): 
                data=str(data).encode("utf-8")   

        written = libcrypto.BIO_write(self.bio, data, len(data))
        if written == -2:
            raise NotImplementedError("Function not supported by this BIO")
        if written < len(data):
            raise IOError("Not all data were successfully written")