Check if directory exists before creating, and set a proper mode

While this worked on Windows, on UNIX, if the directory already exists, the mkdirSync would fail. Also null (0) mode was being set which creates a directory with no permissions for anyone (including the creator) to read or write, so we use standard 0755 permissions.