'Writes the blob to a file and returns its path.'

def WriteBlobToFile(self, request):

    lifetime = 0
    if (not request.more_data):
        lifetime = request.time_limit
        if (lifetime > 0):
            lifetime += 5
    if (request.offset == 0):
        mode = 'w+b'
    else:
        mode = 'r+b'
    temp_file = tempfiles.CreateGRRTempFile(filename=request.write_path, mode=mode)
    with temp_file:
        path = temp_file.name
        temp_file.seek(0, 2)
        if (temp_file.tell() != request.offset):
            raise IOError('Chunks    out    of    order    Error.')
        temp_file.write(request.executable.data)
    return path
