Centralize determination of endianness.

Change-Id: Ia99ed4de2a07fa8959301a50e41cdb0367de46ea
Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>