Using Python to Copy Rotation of Pose Bones
See this section of the api documentation. Setting PoseBone.matrix probably does the calculations required for PoseBone.matrix_basis but does not update the value of the underlying DNA world matrix property, which is wierd. Here is a script which uses the scene.update method: 

import bpy

class BoneMatrixCopier:
    def __init__(self, obj, scene):
        self.obj = obj
        self.scene = scene
        self.pose_bones = obj.pose.bones

    def update(self):
        self.obj.update_tag({'OBJECT'})
        self.scene.update()

    def get_ik_bone_name(self, name):
        return name.replace("Bone", "BoneIK")

    def copy_matrix(self, bone):
        self.update()
        bone.matrix = self.pose_bones[
            self.get_ik_bone_name(bone.name)
            ].matrix

    def copy_matrices(self, root_bone_name):
        root_bone = self.pose_bones[root_bone_name]

        self.copy_matrix(root_bone)
        for bone in root_bone.children_recursive:
            self.copy_matrix(bone)

bmc = BoneMatrixCopier(bpy.data.objects['Armature'], bpy.context.scene)
bmc.copy_matrices('Bone')