Return json correctly from model

Fixes #10

TODO:
- Unify common error returns, such as 404.