How to mirror an animation
So after some googling and reading API I came up with a little script to automate the process:

import bpy

scn = bpy.context.scene

bpy.ops.object.mode_set(mode='POSE')
bpy.ops.pose.select_all(action='SELECT')

initial_keyframe = scn.frame_current

scn.frame_set(0)

while True:
    bpy.ops.anim.keyframe_insert()

    if 'FINISHED' not in bpy.ops.screen.keyframe_jump(next=True):
        break
    else:
        # A hook to update bone positions after jump.
        # See http://blender.stackexchange.com/a/8534/14703
        scn.frame_set(scn.frame_current)

scn.frame_set(0)

while True:
    bpy.ops.pose.copy()
    bpy.ops.pose.paste(flipped=True)
    bpy.ops.anim.keyframe_insert()

    if 'FINISHED' not in bpy.ops.screen.keyframe_jump(next=True):
        break
    else:
        scn.frame_set(scn.frame_current)

scn.frame_set(initial_keyframe)


Running this will x-flip all frames in the animation.
Unfortunately copying and pasting pose creates unwanted keyframes so you may want to clean up the result manually.