code: def write(self, data):
          
          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")
docs: Writes data to writable bio. For test purposes