'Serializes the tko job object into a binary by using a
protocol buffer.
The method takes a tko job object and constructs a protocol
buffer job object. Then invokes the native serializing
function on the object to get a binary string. The string is
then written to outfile.
Precondition: Assumes that all the information about the job
is already in the job object. Any fields that is None will be
provided a default value.
:param
the_job: the tko job object that will be serialized.
tag: contains the job name and the afe_job_id
binaryfilename: the name of the file that will be written to
:return: the filename of the file that contains the
binary of the serialized object.'

def serialize_to_binary(self, the_job, tag, binaryfilename):

    pb_job = tko_pb2.Job()
    self.set_pb_job(the_job, pb_job, tag)
    out = open(binaryfilename, 'wb')
    try:
        out.write(pb_job.SerializeToString())
    finally:
        out.close()
