Use Cow for formats conversions to avoid an allocation and copy
Add fixes and tests for samples conversions