Modified write and writeSync to accept replacer and space argument (just as JSON.stringify does)