add byte-reverse helper function