tests: Use buffers format when writing PPM files

Also change tests to use BGRA by default

Also change WritePPM to use BGRA format
diff --git a/tests/xgltestframework.cpp b/tests/xgltestframework.cpp
index fa648a3..7b83596 100644
--- a/tests/xgltestframework.cpp
+++ b/tests/xgltestframework.cpp
@@ -214,11 +214,27 @@
     file << 255 << "\n";
 
     for (y = 0; y < image->height(); y++) {
-        const char *row = ptr;
+        const int *row = (const int *) ptr;
+        int swapped;
 
-        for (x = 0; x < image->width(); x++) {
-            file.write(row, 3);
-            row += 4;
+        if (image->format() == XGL_FMT_B8G8R8A8_UNORM)
+        {
+            for (x = 0; x < image->width(); x++) {
+                swapped = (*row & 0xff00ff00) | (*row & 0x000000ff) << 16 | (*row & 0x00ff0000) >> 16;
+                file.write((char *) &swapped, 3);
+                row++;
+            }
+        }
+        else if (image->format() == XGL_FMT_R8G8B8A8_UNORM)
+        {
+            for (x = 0; x < image->width(); x++) {
+                file.write((char *) row, 3);
+                row++;
+            }
+        }
+        else {
+            printf("Unrecognized image format - will not write image files");
+            break;
         }
 
         ptr += sr_layout.rowPitch;