def write(self, msg, thread_lock=None, help_msg=False):
        """ msg may or may not be encoded """
        if self.cursesScreen:
            if thread_lock is not None:
                thread_lock.acquire()
            self.cursesScreen.erase()
            try:
                self.msg = msg.strip()
                self.cursesScreen.addstr(0, 1, self.msg[0: self.width]
                                         .replace("\r", "").replace("\n", ""))
            except:
                self.msg = msg.encode('utf-8', 'replace').strip()
                self.cursesScreen.addstr(0, 1, self.msg[0: self.width]
                                         .replace("\r", "").replace("\n", ""))
            self.cursesScreen.refresh()
            if thread_lock is not None:
                thread_lock.release()
            self.last_written_string = msg
            if help_msg or self.display_help_message:
                self.write_right('Press ? for help', thread_lock)
                self.display_help_message = True
msg may or may not be encoded