File io optimization

Memory pipes are fifo structures which for the most part behave like normal files but are much faster due to the fact that the data is stored in memory and not on the disk.
The two main differences are that pipes do not support seek operations, and that they block the thread. 
To get around the blocking issue, after the two pipes are created, I start a thread that then starts the OCR engine process. This worker thread will stay blocked waiting for input until the main thread opens the pipes and writes the data.
After the main thread writes the input data, it waits for the OCR engine's thread to terminate before reading the pipe. That's done to ensure that all the OCR output has been written to the pipe.

Unfortunately, Tesseract does not support stdin and the PIL.image.save function requires seek operation, thus it can't use the pipe. I tried manually saving the pixels to the pipe, but I'm guessing I'm missing some header because Tesseract thinks the file is invalid. For the time being, I put back the file IO.
Writing to a pipe requires both sides of the pipe to be open otherwise the thread will block. That's why I start the worker thread, otherwise the main thread will be blocked and it will never start the worker thread. So basically, you have to do the following:

1. Start the worker thread - it will attempt to read from the pipe, but since nothing is writing to it, the thread will stay blocked. 
2. In the main thread, you write to the pipe by calling image.save. Once data is written to the pipe, the worker thread will be released and will start processing

That's probably why the unit test is hanging.