Use iolist_to_binary/iolist_size instead of custom functions

And avoid some useless conversions