We want to run a gallery workflow from one of our products. The Gallery API fits this need. We're able to start a job with POST /v1/workflows/{appId}/jobs/, see the status of the job with GET /v1/jobs/{jobId}/ and get the output of the job with GET /v1/jobs/{jobId}/output/{outputId}/.
If the output of the job is textual, like a CSV file, and we retrieve it we get the text the file contains. So this works. But now the output of the job is binary, a PDF file. The response we get is still a text while I would expect it to be binary data.

Therefore I'm not sure how to interpret this data and write it to the local file system to make it a functional PDF file again. I'm using Node.js and tried decoding the string with all the character encodings currently supported by Node.js but to no avail. The file is always corrupt or empty.
I did some searching on these forums and on Google but the Gallery API examples and explanations I've found don't go into this much detail. They all stop after getting a response from the API.
The format and attachment parameters as described in the API docs don't seem to have any influence on the response.
Can someone point me in the right direction?