encode data with bson for reduced network traffic