fs: make write/appendFileSync correctly set file mode