ArcGISDynamicMapServiceLayer showing white pixels as transparent even though black pixels are supposed to be background

We are visualizing a tiff image in our web map. We have set the layer properties to say that black pixels are to be treated as background, and that they should be displayed as transparent. Visualizing it in ArcGIS Desktop confirms that this is working properly. However, as soon as the layer is published and the layer is put into a ArcGISDynamicMapServiceLayer, the white pixels seem to become transparent. We cannot seem to identify the cause of this problem.

This is the code (SETTLE_VP_ORTHOPHOTO is a variable storing the rest endpoint for the layer.):