We present a path planning algorithm based on 3D Dubins Curves  for Unmanned Aerial Vehicles (UAVs) to avoid both static and moving obstacles. A variation of Rapidly-exploring Random Tree (RRT)  is used as the planner. In tree expansion, branches of the tree are generated by propagating along 3D Dubins Curves. The node sequence of shortest length together with Dubins curves connecting them is selected as the path. When the UAV executes the path, the path is checked for collision with updated obstacles' states. A new path is generated if the previous one is predicted to collide with obstacles. Such checking and replanning loop repeats until the UAV reaches the goal. The algorithm was validated through flight experiments using a small quadrotor UAV. In total, 6 flights to avoid static obstacles, 24 flights to avoid virtual moving obstacles and 20 flights to avoid real moving obstacles were performed. The efficacy of the algorithm was tested in office conditions and a parking structure. In all the situations our algorithm was able to reliably plan paths in real time and command the UAV to avoid obstacles.