use magic numbers from libmagic instead of hardcoding