set encoding and status error

I know this is not perfect, but we now set encoding and error status code