Python error: TypeError: sequence item 0: expected a bytes-like object, str found?

b"".join(out) would expect an iterable of bytes like objects, However, yours are strings. Try

"".join(out).encode()