Check _output_array flag in api.web.RequestHandler.write_error

In some cases, write_error would set RequestHandler._output to the
wrong type.