Index: /branches/eam_branches/ohana.20150429/src/opihi/cmd.data/read_vectors.c
===================================================================
--- /branches/eam_branches/ohana.20150429/src/opihi/cmd.data/read_vectors.c	(revision 38366)
+++ /branches/eam_branches/ohana.20150429/src/opihi/cmd.data/read_vectors.c	(revision 38367)
@@ -522,4 +522,10 @@
 
     dump_cmp_table (&table, "rd cmp");
+
+    int Nfields;
+    if (!gfits_scan (&header, "TFIELDS", "%d", 1, &Nfields)) ESCAPE ("cannot find TFIELDS in header");
+    for (i = 0; i < Nfields; i++) {
+      gfits_byteswap_varlength_column (&table, i+1);
+    }
     if (!gfits_uncompress_table (&table, &rawtable)) ESCAPE ("failed to uncompress table");
     dump_raw_table (&rawtable, "rd raw");
@@ -541,5 +547,5 @@
     if (Binary) {
       if (!gfits_get_bintable_column_type (outheader, argv[i], type, &Nval)) ESCAPE ("requested field not found");
-      if (!gfits_get_bintable_column (outheader, outtable, argv[i], &data)) ESCAPE ("error reading data from specified field");
+      if (!gfits_get_bintable_column_raw (outheader, outtable, argv[i], &data, IsCompressed)) ESCAPE ("error reading data from specified field");
     } else {
       if (!gfits_get_table_column_type (outheader, argv[i], type)) ESCAPE ("requested field not found");
Index: /branches/eam_branches/ohana.20150429/src/opihi/lib.data/SplineOps.c
===================================================================
--- /branches/eam_branches/ohana.20150429/src/opihi/lib.data/SplineOps.c	(revision 38366)
+++ /branches/eam_branches/ohana.20150429/src/opihi/lib.data/SplineOps.c	(revision 38367)
@@ -178,7 +178,8 @@
   gfits_create_table (&theader, &ftable);
 
-  gfits_set_bintable_column_reformat (&theader, &ftable, "X_KNOT", "double", myspline->xk, myspline->Nknots);
-  gfits_set_bintable_column_reformat (&theader, &ftable, "Y_KNOT", "double", myspline->yk, myspline->Nknots);
-  gfits_set_bintable_column_reformat (&theader, &ftable, "DY2_DX", "double", myspline->y2, myspline->Nknots);
+  // NOTE: if we want to compress the output table, use native byte order here (last element)
+  gfits_set_bintable_column_reformat (&theader, &ftable, "X_KNOT", "double", myspline->xk, myspline->Nknots, FALSE);
+  gfits_set_bintable_column_reformat (&theader, &ftable, "Y_KNOT", "double", myspline->yk, myspline->Nknots, FALSE);
+  gfits_set_bintable_column_reformat (&theader, &ftable, "DY2_DX", "double", myspline->y2, myspline->Nknots, FALSE);
 
   if (!append) {
Index: /branches/eam_branches/ohana.20150429/src/opihi/lib.shell/VectorIO.c
===================================================================
--- /branches/eam_branches/ohana.20150429/src/opihi/lib.shell/VectorIO.c	(revision 38366)
+++ /branches/eam_branches/ohana.20150429/src/opihi/lib.shell/VectorIO.c	(revision 38367)
@@ -2,5 +2,5 @@
   
 // write a set of vectors to a FITS FTable structure (vectors names become fits column names)
-static int WriteVectorTable (FTable *ftable, char *extname, Vector **vec, int Nvec, char *format) {
+static int WriteVectorTable (FTable *ftable, char *extname, Vector **vec, int Nvec, char *format, char nativeOrder) {
   
   int j;
@@ -59,7 +59,7 @@
   for (j = 0; j < Nvec; j++) {
     if (vec[j][0].type == OPIHI_FLT) {
-      gfits_set_bintable_column_reformat (theader, ftable, vec[j][0].name, "double", vec[j][0].elements.Flt, vec[j][0].Nelements);
+      gfits_set_bintable_column_reformat (theader, ftable, vec[j][0].name, "double", vec[j][0].elements.Flt, vec[j][0].Nelements, nativeOrder);
     } else {
-      gfits_set_bintable_column_reformat (theader, ftable, vec[j][0].name, "int", vec[j][0].elements.Int, vec[j][0].Nelements);
+      gfits_set_bintable_column_reformat (theader, ftable, vec[j][0].name, "int", vec[j][0].elements.Int, vec[j][0].Nelements, nativeOrder);
     }
   }
@@ -130,5 +130,6 @@
 
   rawtable.header = &rawheader;
-  if (!WriteVectorTable (&rawtable, extname, vec, Nvec, format)) goto escape;
+  if (!WriteVectorTable (&rawtable, extname, vec, Nvec, format, (compress != NULL))) goto escape;
+  // NOTE : for compression, the table is constructed in native by order 
 
   FTable *outtable = &rawtable;
@@ -139,5 +140,11 @@
 
     dump_raw_table (&rawtable, "wd raw");
-    if (!gfits_compress_table (&rawtable, &cmptable, 10, compress)) goto escape;
+    if (!gfits_compress_table (&rawtable, &cmptable, 0, compress)) goto escape;
+
+    int i, Nfields;
+    if (!gfits_scan (&cmpheader, "TFIELDS", "%d", 1, &Nfields)) goto escape;
+    for (i = 0; i < Nfields; i++) {
+      gfits_byteswap_varlength_column (&cmptable, i+1);
+    }
     dump_cmp_table (&cmptable, "wd cmp");
 
