Replaced file locking code

This fixes the following [error](http://pastebin.com/raw.php?i=L7THN3na) :
> `delete': Permission denied - [some path]/metadata.json (Errno::EACCES)

Details about the problem can be found in [this SO question](http://stackoverflow.com/questions/26298093/weird-file-open-behavior-when-using-different-closure-types-in-ruby)