The content in the todo dict are strings. In python3 the communicate method expects a bytes-like object not a string. Solution: Encode every element in todo to a new dict (enc_todo) and pass this instead of todo