print error messages with correct content-type and formatting when cfg={r,j,json}