diff --git a/src/m_anigif.c b/src/m_anigif.c
index 2c1ceb86b6fc8871cd51c809b1f00f663f8e9881..4f7ed16ab4a82a5e5252792a1b9600de92670633 100644
--- a/src/m_anigif.c
+++ b/src/m_anigif.c
@@ -439,11 +439,9 @@ static void GIF_headwrite(void)
 	else
 	{
 		const UINT8 *pal = (UINT8 *)W_CacheLumpName(GetPalette(), PU_CACHE);
-		for (i = 0; i < 256; i++)
+		for (i = 0; i < 256*3; i++)
 		{
 			WRITEUINT8(p, *pal); pal++;
-			WRITEUINT8(p, *pal); pal++;
-			WRITEUINT8(p, *pal); pal++;
 		}
 	}
 
diff --git a/src/m_misc.c b/src/m_misc.c
index d94df468e350da2708673fa4f39fbf013db7341a..87e65f6ce2cb6dda672f5a83917d15791ab8cae8 100644
--- a/src/m_misc.c
+++ b/src/m_misc.c
@@ -1342,7 +1342,7 @@ typedef struct
   * \param palette  Palette of image data
   */
 #if NUMSCREENS > 2
-static boolean WritePCXfile(const char *filename, const UINT8 *data, int width, int height, const UINT8 *palette)
+static boolean WritePCXfile(const char *filename, const UINT8 *data, int width, int height)
 {
 	int i;
 	size_t length;
@@ -1383,8 +1383,25 @@ static boolean WritePCXfile(const char *filename, const UINT8 *data, int width,
 
 	// write the palette
 	*pack++ = 0x0c; // palette ID byte
-	for (i = 0; i < 768; i++)
-		*pack++ = *palette++;
+
+	// write color table
+	if (cv_screenshot_colorprofile.value)
+	{
+		for (i = 0; i < 256; i++)
+		{
+			*pack++ = pLocalPalette[i].s.red;
+			*pack++ = pLocalPalette[i].s.green;
+			*pack++ = pLocalPalette[i].s.blue;
+		}
+	}
+	else
+	{
+		const UINT8 *pal = (UINT8 *)W_CacheLumpName(GetPalette(), PU_CACHE);
+		for (i = 0; i < 256*3; i++)
+		{
+			*pack++ = *pal++;
+		}
+	}
 
 	// write output file
 	length = pack - (UINT8 *)pcx;
@@ -1460,8 +1477,7 @@ void M_DoScreenShot(void)
 #ifdef USE_PNG
 		ret = M_SavePNG(va(pandf,pathname,freename), linear, vid.width, vid.height, true);
 #else
-		ret = WritePCXfile(va(pandf,pathname,freename), linear, vid.width, vid.height,
-			W_CacheLumpName(GetPalette(), PU_CACHE));
+		ret = WritePCXfile(va(pandf,pathname,freename), linear, vid.width, vid.height);
 #endif
 	}