For anyone trying to figure out how to do this, you can use the Client API: https://apidocs.rnd.mendix.com/8/client/mx.data.html
The specific function I was looking for is:
mx.data.saveDocument(guid, fileName, params, blob, callback, error)
The way I used it is by supplying the JavaScript action I was making with an object that was a Generalization of System.Image and creating a Blob (https://developer.mozilla.org/en-US/docs/Web/API/Blob) of the image in the action, both of which I use in the mx.data.saveDocument function.