[IMPROV] Pickle: Open files in binary mode

With Python 3 files must be open in binary mode to get pickled. This
change also adds 'with' statements to all changes. In wikidataquery.py
this closes the files.

Change-Id: I155d42aeaaed22365309425d59bfb195cd3eddcf
Merge "[IMPROV] Pickle: Open files in binary mode"