Remove non-printable characters from string in Python 3
Something that may help performance wise could be itertools.islice.
This will allow you to call str.isprintable() max_width amount of times,
as this is a binary file that may not have many \ns it can save a lot of effort.

output = line.decode(codec, "replace")
if max_width:
    print("".join(itertools.islice((c for c in output if c.isprintable()), max_width)))
else:
    print(output)


This on it's own may not help on files that have a lot of \ns.
The bottle neck in these file would most likely be the overhead incurred by print.
And so it's much faster to build a string to display once.
In these cases you would want to use something like:
(Untested code)

def read_data(path):
    with open(path) as f:
        for line in f:
            output = line.decode(codec, "replace")
            if max_width:
                yield "".join(itertools.islice(
                    (c for c in output if c.isprintable()),
                    max_width))
            else:
                yield output

print('\n'.join(read_data(...)))


However the above is not good on machines with limited memory or extremely large files.
In these cases you would want to use a buffer and print the buffer when a threshold has been reached.



After PEP 3138 your method to remove non-printables seems to be the correct way.