Use warnings.warn to print warnings

Since the library can be used by command line utilities whose
output could be piped.