title: Reading File from GridFS gives Illegal chunk format Error
body: <p><em>Code:</em></p>
  
  <pre><code>var test_id = new ObjectID();    
  var gridStore = new GridStore(mongoose.connection.db, test_id , 'test_gs_getc_file' , 'w');
      gridStore.open(function(err, gridStore){
          var data = fs.readFileSync('./test.jpg');
          gridStore.write(data, function(err, doc){
              gridStore.close(function(err, doc){
                  GridStore.read(mongoose.connection.db, test_id , function(err, data){
                      if(err){
                          console.log("ERROR", err);
                      }else{
                          console.log("FILE data", data);
                      }
                  })
              })
          })
      })
  </code></pre>
  
  <p>The file is getting saved in the <code>fs.chunks</code> and <code>fs.files</code> collections. 
  But when i try to read the file it gives <code>Illegal chunk format</code> error.</p>
  
  <p>I tried </p>
  
  <ol>
  <li>writeFile method, but it leads to same error</li>
  <li><a href="https://stackoverflow.com/questions/11529458/mongodb-gridfs-illegal-chunk-format-exception">reinstalled mongodb</a>, but it leads to same error</li>
  </ol>
  
  <p><em>Complete Error message:</em></p>
  
  <pre><code>C:\Users\rajsubramanian\nodeapps\populate\node_modules\mongoose\node_modules\mon
  godb\lib\mongodb\connection\server.js:594
          throw err;
                ^
  Error: Illegal chunk format
      at Error (unknown source)
      at new exports.Chunk (C:\Users\rajsubramanian\nodeapps\populate\node_modules
  \mongodb\lib\mongodb\gridfs\chunk.js:43:11)
      at nthChunk (C:\Users\rajsubramanian\nodeapps\populate\node_modules\mongodb\
  lib\mongodb\gridfs\gridstore.js:582:24)
      at Cursor.nextObject (C:\Users\rajsubramanian\nodeapps\populate\node_modules
  \mongoose\node_modules\mongodb\lib\mongodb\cursor.js:680:5)
      at Cursor.nextObject.commandHandler (C:\Users\rajsubramanian\nodeapps\popula
  te\node_modules\mongoose\node_modules\mongodb\lib\mongodb\cursor.js:658:14)
      at Db._executeQueryCommand (C:\Users\rajsubramanian\nodeapps\populate\node_m
  odules\mongoose\node_modules\mongodb\lib\mongodb\db.js:1659:20)
      at g (events.js:192:14)
      at EventEmitter.emit (events.js:126:20)
      at Server.Base._callHandler (C:\Users\rajsubramanian\nodeapps\populate\node_
  modules\mongoose\node_modules\mongodb\lib\mongodb\connection\base.js:410:25)
      at Server.connect.connectionPool.on.server._serverState (C:\Users\rajsubrama
  nian\nodeapps\populate\node_modules\mongoose\node_modules\mongodb\lib\mongodb\co
  nnection\server.js:580:20)
  DEBUG: Program node app exited with code 1
  </code></pre>