Added HTTPS support to downloadFile method