Implement writeFile, support --output and --externs