Write: return number of bytes written