When you save your raster layer as Rendered image
from QGIS, the saved image quality depends on your choosed profile parameters. Please, check your settings to find which of them alters your output quality:
You should understand that when you save the file from the QgsRenderer as in your code:
piperenderer = pipelayer.renderer()
pipe.set(piperenderer.clone())
file_writer.writeRaster(pipe...
You are not saving the raster styled, instead you are saving the actual RGB file that represents that visualization, so it is not classified or styled, but it is like you've taken a print screen of the rendered image.
So gdalwarp and translate can't change this, as it is hardcoded in the image's bands, what must be happening is that they are clipping by a single band or so, I have to check it thorughly.
EDIT
I can see in the xml file you provided that the raster has now only one band
<PAMRasterBand band="1">
There should be the tags:
<PAMRasterBand band="2">
<PAMRasterBand band="3">
So the problem is in gdalogr:warpreproject
. I used the same code you provided in a raster I have but the output is RGB, I don't know what's going on, maybe you should give a sample of your raster file.
NOTE
The xml has no style data, as I said the raster you firstly saved is not a styled layer, but an actual RGB image representing the styled raster.
Best Answer
You can do that in Python Console of QGIS by using a QgsRasterPipe object (pipe) for setting a renderer clone of the image employed as active layer before to use the 'writeRaster' method of QgsRasterFileWriter class (you don't need gdal_translate).
I used the following code:
To test it, I loaded a raster dem (sample_dtm.tif) at the Map Canvas of QGIS and then, it was rendered as a singleband pseudocolor layer with 5 classes (see below image):
After executing the script, the rendered raster (output2.tif) was saved with the espected renderer; as it can be observed in the below image (compare the thumbnails of sample_dtm.tif and output2.tif) when I load output2.tif raster at the Map Canvas. The renderer was effectively cloned in output2.tif raster. The code works.