part 1: length appending
part 2: encode properly