Return compiled command message

@param  {Object|Buffer} data
@return {Buffer}
function encode() {
  var data = this.data;
  var length = 11;
  var sender = this.sender;
  var target = this.target;
  var header = new Buffer(9);
  var content = !data || isBuffer(data) ? data : this.encode(data);

  if (content) length += content.length;

  header.writeUInt8(length, 0);
  header.writeUInt8(sender.subnet, 1);
  header.writeUInt8(sender.id, 2);
  header.writeUInt16BE(sender.type, 3);
  header.writeUInt16BE(this.code, 5);
  header.writeUInt8(target.subnet, 7);
  header.writeUInt8(target.id, 8);

  return content ? Buffer.concat([header, content]) : header;
}