Know your mystery's end before you attempt to write it. This will help you outline your story properly, and center the action around the resolution of the mystery as your main plot. In a puzzle mystery especially, where "red herrings" are often used to keep your reader guessing, it is critical to know how the puzzle fits together before you try to build it. All of the information you include must somehow serve your basic purpose.
Understand basic storytelling structure. The first section is where you will find your inciting incident or precipitating event, and introduce your audience to your characters and what they hope to achieve. The middle section features escalating conflict, and follows red herrings through their different resolutions without directly solving the puzzle. Each event should build on the last. The ending will satisfactorily resolve the mystery, as well as any other sub-plots that revolved around it.
Introduce all the clues needed to solve the puzzle somewhere in your story. You will lose your reader if you attempt to throw curve balls at him at the last minute. It's clunky storytelling and it's inherently unfair to your reader if you use information that was never made privy to him before the critical moment of your reveal. Rather, challenge yourself as a writer to place these clues carefully throughout the story, without making it obvious to the reader that that is what you are doing.
Keep the action moving. Show your reader what is going on rather than waste precious pages on exposition or dialogue. No matter how brilliant you think your witty banter is, it should be concise and always have a purpose, rather than repeating what the reader already knows. Deliver your key information like tiny crumbs that keep the reader hungry for more by arriving late to the scene and leaving early.
Make it credible. When you write a story, you set up unbreakable rules for your reader, whether consciously or unconsciously. Your characters and their circumstances therefore have to remain believable in the context of those rules. This includes their ability to solve the mystery, which should rely upon their particular skill. Supernatural elements or events that are exceptionally out of the ordinary should be used sparingly, if at all, and always make sense within the rules you've already established.
Make your characters three-dimensional. Don't rely on plot convention to churn out stereotypes. Give your characters real traits and flaws that make them accessible to the reader, especially your protagonist. This is your reader's partner in solving the crime, and whether the protagonist is likable or not he or she should be at the very least compelling enough to keep your reader invested.
Make sure that justice prevails. Not only should your reader be able to solve the puzzle, but so should your characters. If it's a crime, the criminal needs to be caught and brought to justice by the direct action of the protagonist.