The distinction is in the Accept request header. If text/html is present, Reddit will freely send you a shitty HTML image viewer instead of the raw image. This can (for the moment) be worked around by modifying or not sending that header for the entirety of the i.redd.it domain.
https://addons.mozilla.org/en-US/firefox/addon/header-editor/
https://chrome.google.com/webstore/detail/header-editor/eningockdidmgiojffjmkdblpjocbhgh