Fix for os.write TypeError: 'str' does not support the buffer interface