The only reason to post an image instead of a pastebin is for engagement. I understand the engagement practices we are subject to on attention marketplaces like twitter, but is it that hard to provide a supplemental pastebin link?
Some locations and people have sites like pastebin blocked, but image hosting allowed. Also in case of say technical blog posts, a combination of certain text characters might trigger a false positive for malware on your site. You don't get that problem with images.
It's not engagement. It's usability. Way better having the image in context than having an external link to a text written with fixed width font. Obviously you should ALSO provide the link to the text in the tweet so one can easily copypaste (if interested in the code/text after seeing the image preview)