gridfs enhancements to support full random reading and writing and chunk pre/post processing

Please, use this pull request for gridfs enhancements.
many parts of gridfs.c were almost re-written, so don't expect incremental changes