Add encode function into Gridfs