Jwang refactor query encoding

If `IOException` is no longer normal behavior then may as well wrap this as a `CatalogException` here right? Why pass the buck upstream?