Index: /trunk/zoo-project/zoo-kernel/service_internal.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/service_internal.c	(revision 618)
+++ /trunk/zoo-project/zoo-kernel/service_internal.c	(revision 619)
@@ -3017,4 +3017,26 @@
       addToMap(cursor->content,"size",sizes);
     }
+    map* length=getMap(cursor->content,"length");
+    if(length!=NULL){
+      int len=atoi(length->value);
+      for(int i=1;i<len;i++){
+	tmp=getMapArray(cursor->content,"encoding",i);
+	if(tmp!=NULL && strncasecmp(tmp->value,"base64",6)==0){
+	  char key[17];
+	  sprintf(key,"base64_value_%d",i);
+	  tmp=getMapArray(cursor->content,"value",i);
+	  addToMap(cursor->content,key,tmp->value);
+	  int size=0;
+	  char *s=strdup(tmp->value);
+	  free(tmp->value);
+	  tmp->value=base64d(s,strlen(s),&size);
+	  free(s);
+	  char sizes[1024];
+	  sprintf(sizes,"%d",size);
+	  sprintf(key,"size_%d",i);
+	  addToMap(cursor->content,key,sizes);
+	}
+      }
+    }
     cursor=cursor->next;
   }
Index: /trunk/zoo-project/zoo-kernel/service_internal_otb.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/service_internal_otb.c	(revision 618)
+++ /trunk/zoo-project/zoo-kernel/service_internal_otb.c	(revision 619)
@@ -95,4 +95,26 @@
     }
     return str;
+}
+
+/**
+ * Write a file from value and length
+ *
+ * @param fname the file name
+ * @param val the value
+ * @param length the value length
+ */
+int writeFile(char* fname,char* val,int length){
+  FILE* of=fopen(fname,"wb");
+  if(of==NULL){
+    return -1;
+  }
+  size_t ret=fwrite(val,sizeof(char),length,of);
+  if(ret<length){
+    fprintf(stderr,"Write error occured!\n");
+    fclose(of);
+    return -1;
+  }
+  fclose(of);
+  return 1;
 }
 
@@ -191,23 +213,34 @@
 		    dynamic_cast<OutputImageParameter *> (param.GetPointer())->SetPixelType(outPixType);
 		  }else{
+		    map* tmpPath=getMapFromMaps(m,"main","tmpPath");
+		    map* tmpSid=getMapFromMaps(m,"lenv","sid");
 		    map* tmpVal=getMapFromMaps(inputs,paramKey.c_str(),"mimeType");
 		    char file_ext[32];
 		    getFileExtension(tmpVal != NULL ? tmpVal->value : NULL, file_ext, 32);
 		    if(type == ParameterType_InputImageList){
-		      values.push_back(test->value);
+		      char *val=(char*)malloc((strlen(tmpPath->value)+strlen(s->name)+strlen(tmpSid->value)+strlen(file_ext)+13)*sizeof(char));
+		      sprintf(val,"%s/Input_%s_%s_%d.%s",tmpPath->value,s->name,tmpSid->value,0,file_ext);
+		      int length=0;
+		      map* tmpSize=getMap(test,"size");
+		      if(tmpSize!=NULL){
+			length=atoi(tmpSize->value);
+		      }
+		      writeFile(val,test->value,length);
+		      values.push_back(val);
+		      free(val);
 		      map* tmpLength=getMapFromMaps(inputs,paramKey.c_str(),"length");
 		      if(tmpLength!=NULL){
 			int len=atoi(tmpLength->value);
+			maps* tmpI=getMaps(inputs,paramKey.c_str());
 			for(int k=1;k<len;k++){
-			  char *val=(char*)malloc((strlen(tmpPath->value)+strlen(s->name)+strlen(tmpSid->value)+strlen(file_ext)+13)*sizeof(char));
+			  val=(char*)malloc((strlen(tmpPath->value)+strlen(s->name)+strlen(tmpSid->value)+strlen(file_ext)+13)*sizeof(char));
 			  sprintf(val,"%s/Input_%s_%s_%d.%s",tmpPath->value,s->name,tmpSid->value,k,file_ext);
-			  FILE* of=fopen(val,"wb");
-			  int length=0;
-			  map* tmpSize=getMap(test,"size");
+			  length=0;
+			  map* tmpV=getMapArray(tmpI->content,"value",k);
+			  tmpSize=getMapArray(tmpI->content,"size",k);
 			  if(tmpSize!=NULL){
 			    length=atoi(tmpSize->value);
 			  }
-			  fwrite(test->value,sizeof(char),length,of);
-			  fclose(of);
+			  writeFile(val,tmpV->value,length);
 			  values.push_back(val);
 			  free(val);
@@ -220,6 +253,4 @@
 			   || type == ParameterType_ComplexInputImage || type == ParameterType_InputVectorData
 			   || type == ParameterType_InputFilename){
-			map* tmpPath=getMapFromMaps(m,"main","tmpPath");
-			map* tmpSid=getMapFromMaps(m,"lenv","sid");
 			char tmp[1024];
 			char* ext="json";
@@ -227,5 +258,4 @@
 			  char *val=(char*)malloc((strlen(tmpPath->value)+strlen(s->name)+strlen(tmpSid->value)+strlen(file_ext)+10)*sizeof(char));
 			  sprintf(val,"%s/Input_%s_%s.%s",tmpPath->value,s->name,tmpSid->value,file_ext);
-			  FILE* of=fopen(val,"wb");
 			  int length=0;
 			  map* tmpSize=getMap(test,"size");
@@ -233,6 +263,5 @@
 			    length=atoi(tmpSize->value);
 			  }
-			  fwrite(test->value,sizeof(char),length,of);
-			  fclose(of);
+			  writeFile(val,test->value,length);
 
 			  if(strncasecmp(tmpVal->value,"application/zip",14)==0){
