Import gzip and bz2 only if necessary.