Fix dump course structure when element metadata uses opaque keys.

Make sure that during the serialization, all opaque keys and their
references and serialized using the `unicode` function.

AN-3821
Merge pull request #5673 from rocha/fix-course-structure-command

Fix dump course structure when element metadata uses opaque keys.