private void writeFiles(DataOutputStream dataOut, TempFileInfo[] fileToWrite, int resolution) throws IOException, FileNotFoundException {
        final int sizeOfBuffer = 1024;
        byte[] byteTempArray = new byte[sizeOfBuffer];
        
        
        
        for (TempFileInfo info3 : fileToWrite) {
            
            
            byte[] outputBytes = new byte[(int) info3.actualLength];
            int pointInOutput = 0;
            
            File f = new File(Constants.getRoot(), info3.file + "-0");
            try (FileInputStream in = new FileInputStream(f)) {
                IOUtils.skipFully(in, info3.offset);
                int current = 0;
                int posInFile = 0;
                while (current < info3.length)
                {
                   
                    int numOfBytesRead = IOUtils.read(in, byteTempArray, 0, sizeOfBuffer);
                    current+= numOfBytesRead;
                    
                    if (current > info3.length)
                        current = (int) info3.length;
                    
                    
                    
                    
                    for (;posInFile < current/2 && pointInOutput < info3.actualLength; posInFile += resolution)
                    {
                        System.out.printf("I am adding something at %d, %d, %d, %d, %d\n",pointInOutput,posInFile,current,current/2,info3.actualLength);
                        outputBytes[pointInOutput++] = byteTempArray[posInFile*2 - (current - numOfBytesRead)];
                        outputBytes[pointInOutput++] = byteTempArray[posInFile*2+1 - (current - numOfBytesRead)];
                        
                    }
                    
                    
                }
                if (info3.actualLength != pointInOutput)
                    throw new RuntimeException("Did not actually read in all stuff");
               
                System.out.println("Writing at " + System.currentTimeMillis());
                IOUtils.write(outputBytes, dataOut);
                
                
                System.out.println(f.getAbsolutePath() + " : " + outputBytes.length);
            }
        }
    }