Fixed ~ expansion bug

In Mac OS X '~' will not expand to the user directory. Instead, a directory by the name of '~' will be created. This patch fixes this issue.
Merge pull request #46 from allfro/patch-1

Fixed ~ expansion bug