Fixed download of attachments to not use temp files
Refactored to comply to PEP8