You set it up so the piston expands upwards once every other tick or so, so it is moving quickly. Then place the block wished to dupe above the piston, so it pushes it upwards. Next, place any block below the block wished to dupe so the piston quickly pushes it up, the block pushed up turns into the block above it. Screenshots below with an example.
First: Redstone layout, the block chosen to duplicate is a diamond block.
Second: Example of placing block below the block choesen to duplicate (diamond)
Third: After placing dirt blocks, dirt transforms into diamond blocks.