Image encryption based on a chaos system can effectively protect the privacy of digital images. It is said that a 3D chaotic system has a larger parameter range, better unpredictability and more complex behavior compared to low-dimension chaotic systems. Motivated by this fact, we propose a new image cryptosystem that makes use of a 3D chaotic system. There are three main steps in our scheme. In the first step, the chaotic system uses the hash value of the plaintext image to generate three sequences. In step two, one of the sequences is used to dynamically select confusion and diffusion methods, where confusion and diffusion have three algorithms, respectively, and will produce 32n (n > 100) combinations for encryption. In step three, the image is divided into hundreds of overlapping subblocks, along with the other two sequences, and each block is encrypted in the confusion and diffusion process. Information entropy, NPCR, UACI results and various security analysis results show that the algorithm has a better security performance than existing, similar algorithms, and can better resist clipping, noise, statistical analysis and other attacks.