reordered DSO link command
encoding now works for both grayscale and color input

- using the RGB32 pixel format
- writeFrameGrayscale() renamed to writeFrame()
- extra checks in writeFrame() to make sure the given image is valid
don't unlock a mutex before destroying it.

This only matters if I'm killing a mutex that's actively being used. This is
wrong anyway, so I do nothing