Shared serialize and deserialize gridfs function for april-ann