Return 501 error when python code fails, and show traceback in error message.

This commit also introduces an "error page" handler, to better format the error
messages (with newlines, etc., showing up properly).
Merge branch 'better-error-reporting'