lib: fix double conversion in write()

The input buffer got converted twice. Not harmful but wasteful.