amzirc: refactor around encoding handlers