<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def ToByteArray(self):
 """Serialize the command. Encodes the command as per the U2F specs, using the standard ISO 7816-4 extended encoding. All Commands expect data, so Le is always present. Returns: Python bytearray of the encoded command. """

    lc = self.InternalEncodeLc()
    out = bytearray(4)  # will extend

    out[0] = self.cla
    out[1] = self.ins
    out[2] = self.p1
    out[3] = self.p2
    if self.data:
      out.extend(lc)
      out.extend(self.data)
      out.extend([0x00, 0x00])  # Le
    else:
      out.extend([0x00, 0x00, 0x00])  # Le
    return out