Bake Keyframes selected bone
--bpy.ops.nla.bake(frame_start = context.scene.frame_start, frame_end = context.scene.frame_end, visual_keying=True, bake_types={'OBJECT'})--

which means you bake all your frames using an NLA editor.