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 #47 from allfro/patch-2

Fixed ~ expansion bug