Avoid race condition when creating directory.
Merge pull request #82 from anthonyfk/master

Solution for issue #81.