def METHOD_NAME(frame, frame_no, out_dir, file_name, file_format, ff_dt, fps, half_frame=None):
    """ Save the file in an appropriate format. """
    # If the metal PNG format was given, convert the file to a 16-bit PNG and byteswap it
    if file_format == 'pngm':
        # Convert to 16 bit PNG
        frame = frame.astype(np.uint16)
        # Byteswap the PNG
        frame = frame.byteswap()
        file_format = 'png'
    # Construct the file name
    file_name_saving = file_name + '_{:03d}'.format(frame_no)
    if half_frame is not None:
        file_name_saving += ".{:d}".format(int(5*half_frame))
    file_name_saving = file_name_saving + '.' + file_format
    # Save the frame to file
    out_path = os.path.join(out_dir, file_name_saving)
    # Save the image to file
    cv2.imwrite(out_path, frame)
    print('Saved:', out_path)
    if half_frame is None:
        half_frame_time = 0
    else:
        half_frame_time = 0.5*half_frame
    # Compute the frame datetime
    frame_dt = ff_dt + datetime.timedelta(seconds=(frame_no + half_frame_time)/float(fps))
    return file_name_saving, frame_dt