encode strings into binary arrays and back again