compress file, but very slow, need optimization