// Called by asynchronous events to send data to server
    void PopulateBuffers()
    {
        // Get our data as a byte[][] and each byte buffer's length in pixels
        manager.GetPixels(out rawPixelData);

        // Break our data into chunks
        // which instance, which chunk is this, total chunks, how long is the buffer, lastpixelIndex
        const int metaIntPieces = 5;
        int       metaOffset    = sizeof(int) * metaIntPieces;

        // Offset for our metadata
        int actualPixelChunkSize = chunkLength - metaOffset;

        for (int i = 0; i < rawPixelData.Length; i++)
        {
            // Get how many chunks we are going to need for each image
            numChunks[i] = Mathf.CeilToInt((float)rawPixelData[i].Length / (float)actualPixelChunkSize);

            // Re-init our chunk array to the correct number of chunks
            rawPixelChunks[i]   = new byte[numChunks[i]][];
            finalPixelChunks[i] = new byte[numChunks[i]][];

            for (int j = 0; j < numChunks[i]; j++)
            {
                // Fill our chunkBuffer with chunks of size actualPixelChunkSize (save room for metadata) from the raw data
                // IF we do not have enough to fill the chunk size, grab the rest of the bytes
                int lengthOfSubarray = Mathf.Min(actualPixelChunkSize, rawPixelData[i].Length - (j * actualPixelChunkSize));
                rawPixelChunks[i][j] = util.Utility.SubArray <byte>(rawPixelData[i], j * actualPixelChunkSize, lengthOfSubarray);

                // Get our metadata
                int[] metaIntData = new int[metaIntPieces] {
                    i, j, numChunks[i], chunkLength, lengthOfSubarray
                };
                byte[] metaData = new byte[metaOffset];
                Buffer.BlockCopy(metaIntData.ToArray(), 0, metaData, 0, metaOffset);

                // Combine metadata and our pixel data into one buffer
                List <byte> finalPixelChunkList = new List <byte>();
                finalPixelChunkList.AddRange(metaData);
                finalPixelChunkList.AddRange(rawPixelChunks[i][j]);
                finalPixelChunks[i][j] = finalPixelChunkList.ToArray();
            }
        }
    }