RippleAPI how to issue IOUs using preparePayment
Okay I figured it out: first, I set up a trustline from USER_ADDR to GATEWAY_ADDR for 1000 EUR. I made sure that the qualityIn and qualityOut were set to 0, the default value:

var trustline = {
  "currency": "EUR",
  "counterparty": GATEWAY_ADDR, 
  "limit": "1000",
  "ripplingDisabled": true,
  "frozen": false,
  "memos": [
    {
      "type": "test2",
      "format": "plain/text",
      "data": "texted data2"
    }
  ]
};


I signed and submitted this trustline.

I then used the following payment object to create an IOU for 50 EUR from the gateway to the user, indicating that the user had deposited 50 EUR with the gateway outside the Ripple system:

const payment = {
  source: {
    address: GATEWAY_ADDR,
    maxAmount: {
      currency: 'EUR',
      value: '50',
      counterparty: GATEWAY_ADDR
    }
  },
  destination: {
    address: USER_ADDR,
    amount: {
      currency: 'EUR',
      value: '50',
      counterparty: GATEWAY_ADDR
    }
  }
};


Earlier, this was not working due to qualityIn and qualityOut being to 0.91 and 0.87