Convert opening filehandles to use `with`.

Converted `filehandle = open(filename, "rb")` to `with open(filename, "rb") as filehandle:` where possible.