'Writes all of the object reference offsets.'

def writeOffsetTable(self, output):

    all_positions = []
    writtenReferences = list(self.writtenReferences.items())
    writtenReferences.sort(key=(lambda x: x[1]))
    for (obj, order) in writtenReferences:
        if (six.PY3 and (obj == six.u(''))):
            obj = six.b('')
        position = self.referencePositions.get(obj)
        if (position is None):
            raise InvalidPlistException(('Error    while    writing    offsets    table.    Object    not    found.    %s' % obj))
        output += self.binaryInt(position, self.trailer.offsetSize)
        all_positions.append(position)
    return output
