Write JSON to file