Added support for arbitrary bit depths up to 32 bits, and arbitrary number of channels.