Ensure types match when resolving references

When resolving references, the object_map indexes values by the python value
of the id fields, but the DBRef uses a type that is serialized into mongo.
In cases where there is a mismatch between the two, such as the case when
the primary key is a non-binary UUID field, instance resolution failed. This
change will ensure that the types used will always be the mongo types,
removing the possiblility of mismatch.