use encode() instead of bytes() for str -> bytes conversion