Add python3.x compatibility and more robust downloading

Since the Requests library is compatible with both Python 2.7 and 3.x and is a dependency of DerPyBooru anyway, using that instead of standard urllib module would be sensible so that the same code can run on newer versions.

I've also tweaked the downloading behavior where it won't write to file until the download is finished, that way incomplete files don't get written if the program is terminated prematurely.

Lastly, I've added a sha512 checksum test to ensure that the downloaded file is correct and not tampered before being saved, otherwise the file write is skipped.