Fixed bug where pointer was cast to ssize_t and returned as number of bytes written. This caused writes to fail in cases where the pointer was interrpreted as a negative number.