Small utility for encoding