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