p = Popen(['/path/to/binary/utility', '-l', 'nl'], stdin=PIPE, stdout=
    PIPE, stderr=PIPE)
out, err = map(lambda b: b.decode('utf-8').replace(os.linesep, '\n'), p.
    communicate(('\xa1Basta Ya!' + os.linesep).encode('utf-8')))
How to fix an encoding migrating Python subprocess to unicode_literals?