some bson encoding optimizations

makes some tests about 10% faster
Merge pull request #37 from Pomyk/bson_opt

some bson encoding optimizations