consistently return bytes instead of ints, and properly trigger key errors