Fix the file mode issue in fs.writeFileSync method

The current implementation of writeFileSync method does NOT pass options.mode to openSync. As a result, the mode is not honored when files are created. The patch will fix the problem. A test case is included too.