Add advisory file locking.

This commit adds advisory locking via flock() to the database file. This ensures that two separate
processes cannot both open the same data file which would cause corruption.

Fixes #110.
Merge pull request #111 from benbjohnson/flock

Add advisory file locking.