According to Apple's Threading Programming Guide:
The following classes and functions are generally not thread-safe. In most cases, you can use these classes from any thread as long as you use them from only one thread at a time....
NSImage. For more information, see NSImage Restrictions.
Post
Replies
Boosts
Views
Activity
Replacing .write(to: output, atomically: true, encoding: .utf8) with .write(to: output, atomically: false, encoding: .utf8) fixed my issue; thanks @rico95