Add bounds check for 4-byte encoding