Bson encoder/decoder implementation