use JSON error pages

Fixes #39.
/cc @dlindquist & @kainswor for code review