Fix. Handle multiple versions of libmagic and try accommodate for related bugs.

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