Add model.js script generation

@raymondfeng @bajtos please review
Should we cache the template, since it is static? Perhaps read it synchronously at `require` time?