Fix crashes in multithreaded server
- Moved SyncOutputStream to its own header file
- Added locking in cycles_server because of multithreaded use
- Bug NOT fixed: Rendered viewport deadlocks