Reimplemented tidy_bytes to handle mish-mash encoding