Fixed 20368 -- Make TECHNICAL_500 more resilient.

This limits large variables and non-utf-8 in the TECHNICAL_500 output.

https://code.djangoproject.com/ticket/20368
https://code.djangoproject.com/ticket/20534
(may not fix the former one, since I don't know how to reproduce)