Work extraction from a heat engine in a cycle by a quantum mechanical device (quantum piston) is analyzed. The standard definition of work fails in the quantum domain. The correct extractable work and its efficiency bound are shown to crucially depend on the initial quantum state of the piston. The transient efficiency bound may exceed the standard Carnot bound, although it complies with the second law. Energy gain (e.g. in lasing) is shown to drastically differ from work gain.