"Context is incorrect" python error, while script moves modifier up in modifier list during rendering
Match the area that the operator is called from in UI.

The operator bpy.ops.object.modifier_move_up when run from the UI is done in the properties area.  (area.type == 'PROPERTIES').  Properties has some extra context members, context.modifiers being one of those.

As well as "modifier" the error message is also complaining about "object" not being a member of over-ridden context.  

import bpy

object_name = "Cube"

bpy.app.handlers.frame_change_post.clear()

win = bpy.context.window
scr = win.screen
areas3d = [area for area in scr.areas if area.type == 'PROPERTIES']
region = [region for region in areas3d[0].regions if region.type == 'WINDOW']

override = {'window': win,
            'screen': scr,
            'area': areas3d[0],
            'region': region[0],
            }

def my_handler(scene):

    print("Frame Change", scene.frame_current)
    obj = scene.objects.get(object_name)
    if obj is None:
        return
    mod = obj.modifiers.get("Mask")
    # delete mask-modifier and add new to last but one position
    if mod:
        obj.modifiers.remove(mod)

    mod = obj.modifiers.new("Mask", type="MASK")
    override["modifier"] = mod
    # perhaps works without these 2 but hey???
    override["object"] = obj
    override["active_object"] = obj
    # avoid hassles by adding scene here
    override["scene"] = scene
    #################################################
    bpy.ops.object.modifier_move_up(override, modifier="Mask")
    #################################################

bpy.app.handlers.frame_change_post.append(my_handler)