Fix the locking issues with multiple processes

 * This bug fixes a race condition if multiple tilda
   instances are loading simultaneously and try to
   determine their instance number to create the lock file.
 * We now use a global lock file and flock() to obtain the
   lock.
 * This patch also properly closes open lock files.
 * Fixes #82
Merge branch 'features/improvelocking'