Add number of fixes to circumvent issues with libmagic.

Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>