use write_error instead of get_error_html

get_error_html is removed in tornado 4.0

closes #6312

should be backported to 2.x, since it's a compatibility issue.