Move python3 check and pkcs5_unpad lambda to the head of the script.