code: function fsWrite(fd, buffer, position, callback) {
    var offset = 0,
        length = buffer.length;
  
    function writeChunk() {
      fs.write(fd, buffer, offset, length - offset, position, function (err, bytesWritten) {
        if (err) { callback(err); return; }
        offset += bytesWritten;
        if (offset < length) {
          writeChunk();
          return;
        }
        callback();
      });
    }
    writeChunk();
  }
docs: Writes a buffer to a specified file descriptor at the given offset handles chunking for you. Callback gets (err)