Be more informative when unable to JSON serialize

Instead of raising a bare TypeError, let the user know where it went wrong.