added replacer and space arguments to write and writeSync methods